home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / firefox-3.0.14 / firefox.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2009-09-07  |  3.9 KB  |  143 lines

  1. #!/bin/sh
  2.  
  3. # Firefox launcher containing a Profile migration helper for
  4. # temporary profiles used during alpha and beta phases.
  5.  
  6. # Authors:
  7. #  Alexander Sack <asac@jwsdot.com>
  8. #  Fabien Tassin <fta@sofaraway.org>
  9. #  Steve Langasek <steve.langasek@canonical.com>
  10. # License: GPLv2 or later
  11.  
  12. MOZDIR=$HOME/.mozilla
  13. LIBDIR=/usr/lib/firefox-3.0.14
  14. APPVER=3.0
  15. META_NAME=firefox
  16. GDB=/usr/bin/gdb
  17. DROPPED=abandoned
  18.  
  19. NAME="$0"
  20. if [ "x$META_NAME" != "x" ] ; then
  21.   NAME="${NAME%%-$APPVER}"
  22. fi
  23. APPNAME="$(basename "$NAME")"
  24.  
  25. while [ ! -f "$LIBDIR/$APPNAME" ] && [ -L "$NAME" ]; do
  26.   TARGET="$(readlink "$NAME")"
  27.   if [ "x$TARGET" = "x$(basename "$TARGET")" ]; then
  28.     TARGET="$(dirname "$NAME")/$TARGET"
  29.   fi
  30.   if [ "x$META_NAME" != "x" ] ; then
  31.     TARGET=${TARGET%%-$APPVER}
  32.   fi
  33.   NAME="$TARGET"
  34.   APPNAME="$(basename "$NAME")"
  35.   if [ "x$APPNAME" = "xfirefox.sh" ]; then
  36.     APPNAME=firefox
  37.     break
  38.   fi
  39. done
  40.  
  41. usage () {
  42.   $LIBDIR/$APPNAME -h | sed -e 's,/.*/,,'
  43.   echo
  44.   echo "        -g or --debug        Start within $GDB (Must be first)"
  45. }
  46.  
  47. want_debug=0
  48. while [ $# -gt 0 ]; do
  49.   case "$1" in
  50.     -h | --help | -help )
  51.       usage
  52.       exit 0 ;;
  53.     -g | --debug )
  54.       want_debug=1
  55.       shift ;;
  56.     -- ) # Stop option prcessing
  57.       shift
  58.       break ;;
  59.     * )
  60.       break ;;
  61.   esac
  62. done
  63.  
  64. # if there exists a beta profile (first found: $MOZDIR/firefox-3.0,
  65. # $MOZDIR/firefox-trunk, $MOZDIR/granparadiso) and there is a standard
  66. # firefox profile as well, ask the user what to do. In case he decides to
  67. # import the firefox 2 profile settings, we keep the firefox directory
  68. # untouched, but rename the beta profile by appending the suffix
  69. # |.abandoned|. In case the user decides to keep using the firefox 3
  70. # profile, we will rename the original firefox profile to firefox.2-replaced
  71. # and rename the beta profile to be |.mozilla/firefox|.
  72. #
  73. # as a third option the user can defer his final decision. This will leave the
  74. # directories untouched, thus making the user use the old firefox profile by
  75. # default.
  76. #
  77. # in addition, even older profiles are renamed too, by appending |.abandoned|
  78. # to their name.
  79.  
  80. FOUND=""
  81. if [ -d $MOZDIR/firefox ] ; then
  82.   FOUND=firefox
  83. fi
  84.  
  85. FOUND_BETA=""
  86. BETA_LIST=""
  87. for betaname in granparadiso firefox-trunk firefox-3.0; do
  88.   if [ -d $MOZDIR/$betaname ]; then
  89.     BETA_LIST="$BETA_LIST $betaname"
  90.     FOUND_BETA=$betaname
  91.   fi
  92. done
  93.  
  94. if [ "$FOUND" != "" -a "$FOUND_BETA" != "" ] ; then
  95.   echo -n "Found Beta Participation ..."
  96.   $LIBDIR/ffox-3-beta-profile-migration-dialog
  97.   result=$?
  98.   if [ $result = 1 ]; then
  99.      mv $MOZDIR/$FOUND $MOZDIR/$FOUND.2-replaced
  100.      mv $MOZDIR/$FOUND_BETA $MOZDIR/$FOUND
  101.      for beta in $BETA_LIST ; do
  102.        if [ $beta != $FOUND_BETA ] ; then
  103.          mv $MOZDIR/$beta $MOZDIR/$beta.$DROPPED
  104.        fi
  105.      done
  106.      echo " keep beta profile."
  107.   elif [ $result = 2 ]; then
  108.      for beta in $BETA_LIST ; do
  109.        mv $MOZDIR/$beta $MOZDIR/$beta.$DROPPED
  110.      done
  111.      echo " use firefox 2 profile."
  112.   else
  113.      echo " use firefox 2 profile, but will ask again next time."
  114.   fi
  115.   echo " ... will check again next time."
  116. elif [ "$FOUND_BETA" != "" -a "$FOUND" = "" ]; then
  117.   # in case we only have a beta profile the user most likely wants to use
  118.   # that. just doing, no questions asked.
  119.   mv $MOZDIR/$FOUND_BETA $MOZDIR/firefox
  120.   for beta in $BETA_LIST ; do
  121.     # Move out the older beta profiles
  122.     if [ $beta != $FOUND_BETA ] ; then
  123.       mv $MOZDIR/$beta $MOZDIR/$beta.$DROPPED
  124.     fi
  125.   done
  126.   echo "*NOTICE* Profile $FOUND_BETA found and moved as main profile"
  127. fi
  128.  
  129. if [ $want_debug -eq 1 ] ; then
  130.   if [ ! -x $GDB ] ; then
  131.     echo "Sorry, can't find usable $GDB. Please install it."
  132.     exit 1
  133.   fi
  134.   tmpfile=`mktemp /tmp/mozargs.XXXXXX` || { echo "Cannot create temporary file" >&2; exit 1; }
  135.   trap " [ -f \"$tmpfile\" ] && /bin/rm -f -- \"$tmpfile\"" 0 1 2 3 13 15
  136.   echo "set args ${1+"$@"}" > $tmpfile
  137.   echo "$GDB $LIBDIR/$APPNAME -x $tmpfile"
  138.   $GDB "$LIBDIR/$APPNAME" -x $tmpfile
  139.   exit $?
  140. else
  141.   exec $LIBDIR/$APPNAME "$@"
  142. fi
  143.